<?php
abstract class Model_Category extends Model {
	 
	/* @var $cate Helper_Category */
	protected  $_Cate;
	protected $_rootId = -1;
	
    //overloading function
    function __call($method, $args){
        return call_user_func_array(array($this->_Cate, $method), $args);
    }
	
    function __construct(){
    	parent::__construct();

    	//配置使用category helper的信息
    	$config  = array(
    		'VAR_TABLE' => $this->tbName,
    		'ROOT_ID'	=> $this->_rootId,
    	);
    	$this->_Cate = new Helper_Category($config);
    	//尝试加载缓存
		if(!$this->loadCache()){
			$this->loadData($this->select("*","order by sequence")); //未加载缓存,则载入原始数组
		}
    }
    
    /**
     *在读取每条数据后...
     **/
	protected function _after_select_fetch(&$row){
	}
	
	function getOption(){
		return $this->getChildren($this->_rootId, true, true, "option");
	}
}
?>